<template>
  <div>
    <h1 style="font-size: 28px">设备数据消息详情</h1>
    <div>
      <a-form :label-col="{ span: 4 }" :wrapper-col="{ span: 14 }">
        <a-form-item label="数据ID">
          <a-input :value="id" disabled/>
        </a-form-item>
        <a-form-item label="消息ID">
          <a-input :value="msg_id" disabled/>
        </a-form-item>
        <a-form-item label="消息类型">
          <a-input :value="type" disabled/>
        </a-form-item>
        <a-form-item label="设备ID">
          <a-input :value="device_id" disabled/>
        </a-form-item>
        <a-form-item label="温度">
          <a-input :value="temperature_value" disabled/>
        </a-form-item>
        <a-form-item label="电量">
          <a-input :value="power" disabled/>
        </a-form-item>
        <a-form-item label="状态码">
          <a-input :value="state" disabled/>
        </a-form-item>
        <a-form-item label="温度状态">
          <a-input :value="temperature_state" disabled/>
        </a-form-item>
        <a-form-item label="防拆状态">
          <a-input :value="tamper_state" disabled/>
        </a-form-item>
        <a-form-item label="温度校准状态">
          <a-input :value="correct_state" disabled/>
        </a-form-item>
        <a-form-item label="创建人">
          <a-input :value="creator_name" disabled/>
        </a-form-item>
        <a-form-item label="消息创建时间">
          <a-input :value="create_time" disabled/>
        </a-form-item>
        <a-form-item label="设备安装时间">
          <a-input :value="install_time" disabled/>
        </a-form-item>
        <a-form-item label="距离安装时间">
          <a-input :value="total_time" disabled/>
        </a-form-item>
        <a-form-item :wrapper-col="{ span: 14, offset: 4 }">
          <a-button style="width: 140px;" @click="onBack">返回</a-button>
        </a-form-item>
      </a-form>
    </div>
  </div>
</template>
<script lang="ts">
import {defineComponent, reactive, toRefs} from "vue";
import {CoreUtils} from "/@/utils/coreUtils";

export default defineComponent({
  name: 'InfoMsgDetail',
  props: {
    item: {
      type: Object,
      default: null,
    },
    viewType: {
      type: String,
      default: null,
    }
  },
  setup(props, {emit}) {
    const data = reactive({
      id: props.item.id,
      msg_id: props.item.msg_id,
      type: props.item.type+'/'+props.item.type.toString(16),
      device_id: props.item.device_id,
      temperature: props.item.temperature,
      temperature_value: props.item.temperature_value + "℃",
      power: props.item.power + "%",
      state: props.item.state,
      temperature_state: props.item.temperature_state == 0 ? "正常":"异常",
      tamper_state: props.item.tamper_state == 0 ? "正常":"异常",
      correct_state: props.item.correct_state == 0 ? "正常":"异常",
      creator_name: props.item.creator_name,
      create_time: props.item.create_time,
      install_time: props.item.install_time,
      total_time: CoreUtils.getDuration(props.item.total_time),
    });

    const onBack = () => {
      emit("my-emit", 'Cancel');
    }

    return {
      ...toRefs(data),
      onBack,
    };
  }

});

</script>

<style scoped>

</style>
